<?php PageUtil::addVar("stylesheet","<link href=\"".$stylepath."/forum.css\" rel=\"stylesheet\">");?>

<!-- tiny mce -->
<script type="text/javascript" src="<?php echo $jspath.'/tinymce/tinymce.dev.js'; ?>"></script>
<script>
  tinymce.init({
    selector: "textarea#elm1",
    theme: "modern",
    menubar : false,
    height : 350,
    plugins: [
      "advlist autolink  image lists charmap print preview hr anchor pagebreak spellchecker",
      "searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
      "save table contextmenu directionality emoticons template paste textcolor importcss"
    ],
    add_unload_trigger: false,

    toolbar: "insertfile undo redo | bold italic | alignleft aligncenter alignright alignjustify | forecolor fullpage backcolor  preview  ",

    image_advtab: true,

    style_formats: [
      {title: 'Bold text', format: 'h1'},
      {title: 'Red text', inline: 'span', styles: {color: '#ff0000'}},
      {title: 'Red header', block: 'h1', styles: {color: '#ff0000'}},
      {title: 'Example 1', inline: 'span', classes: 'example1'},
      {title: 'Example 2', inline: 'span', classes: 'example2'},
      {title: 'Table styles'},
      {title: 'Table row 1', selector: 'tr', classes: 'tablerow1'}
    ]
  });
</script>
<!-- -->
<div class="left_content">
	<form action="<?php echo base_url('forum/add'); ?>" method="post" class="form-horizontal" enctype="multipart/form-data">
    <input type="hidden" name="id" value="<?php echo $data[0]['id']?>" class="span7"/>
		<legend>โพสกระทู้</legend>
		<div class="control-group">
	      <label class="control-label" for="name">หัวข้อกระทู้</label>
	      <div class="controls">
				  <input type="text" name="title" value="<?php echo $data[0]['title']?>" class="span7"/>
	      </div>
	    </div>
      <div class="control-group">
        <label class="control-label" for="Username">หมวดหมู่</label>
        <div class="controls">
          <select name="cat_id">
            <option value="0">โปรดเลือก</option>
            <?php
              echo Util::buildCategoriesOptionList(0,$categories,"",$data[0]['cat_id']);
            ?>
          </select>
        </div>
      </div>
	    <div class="control-group">
        <label class="control-label" >เนื้อหากระทู้</label>
        <div class="controls">
          <textarea id="elm1" class="input-xlarge required" name="content"><?php echo $data[0]['content']?></textarea>
  		  </div>
      </div>
      <div class="control-group">
        <label class="control-label" >ภาพประกอบ</label>
        <div class="controls">
      <?php
        if(!empty($data[0]["images"]) AND count($data[0]["images"]) > 0){
          foreach ($data[0]["images"] as $key => $value) {

          ?>
              <div class="holder_wrap">
                <a href="<?php echo base_url('forum/delete_image/'.$value['id']);?>" class="btn" onClick="return confirm('คุณแน่ใจว่าจะลบใช่หรือไม่');"><i class="icon-trash"></i></a>
                <img src="<?php echo base_url($value['small']);?>" width="110"/>
              </div>
          <?php
          }
        }
      ?>
        </div>
        <div class="controls">
          <input type="file" name="filename[]" class="upload_main" /> <br / >
          <input type="file" name="filename[]" class="upload_main" /> <br / >
          <input type="file" name="filename[]" class="upload_main" /> <br / >
          <input type="file" name="filename[]" class="upload_main" /> <br / >
          <input type="file" name="filename[]" class="upload_main" /> <br / >
        </div>
      </div>

		<div class="control-group">
	      <div class="controls">
                    <input type= "hidden" name= "id"  value= "<?php echo $data[0]['id'];?>">
					<input type="submit" name="submit" value="submit"  class="btn btn-primary" /> &nbsp;
					<input type="reset" name="cancel" value="cancel"  class="btn" />
	      </div>
	    </div>
	</form>
</div>